
Page({

  /**
   * 页面的初始数据
   */
  data: {
    schema:[
      {
        label:'裁剪比例',
        prop:'cropScale',
        type:'picker',
        labelOptions:['宽高比为16比9','宽高比为9比16','宽高比为4比3', '宽高比为3比4', '宽高比为5比4', '宽高比为4比5', '宽高比为1比1'],
        valueOptions:['16:9', '9:16', '4:3', '3:4', '5:4','4:5','1:1'],
      }
    ],
    formData:{
      cropScale: '16:9'
    },
    title: '',
    result: '',
    remark: '',
    webUrl: '',
    apiName: ''
  },
  onLoad(options) {
    console.log('options', options)
    wx.setNavigationBarTitle({
      title: options.title,
    })
    
    this.setData({
      title: options.title,
      zh:options.zh,
      remark: options.remark,
      webUrl: options.webUrl
    })
  },
  getFormData(e) {
    this.setData({
      formData: e.detail.formData
    })
  },
  chooseImage1() {
    this.setData({
      formData: {
        ...this.data.formData,
        url: '../../image/icon_foot.png'
      }
    })
  },
  chooseImage() {
    const that = this;
    wx.chooseImage({
      success (res) {
        that.setData({
          formData: {
            ...that.data.formData,
            url: res.tempFilePaths[0]
          }
        })
      }
    })
  },
  choose1(e) {
    const that = this;
    wx.cropImage({
      src: this.data.formData.url,
      cropScale: this.data.formData.cropScale,
      success(res) {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      fail(err) {
        that.setData({
          result: err,
          apiName: e.currentTarget.dataset.apiname
        })
      } 
    })
  },
  onUnload() {
  }
})